#include "CRL_ShaderDescriptor.h"
#include "CBL_XMLSerializer.h"
#include "CBL_FileSystem.h"
#include "CRL_ShaderEffectDescriptor.h"
#include "CRL_ShaderBundleDescriptor.h"
#include "CRL_Main.h"

CB_SUBNAMESPACE_START(RenderLib)

#define ENUM_ITEM(_Name, _Class) #_Name,
const char* CShaderProgramDescriptor::s_LanguageTypeNames[CShaderProgramDescriptor::NumLanguageTypes] = 
{
	#include "CRL_ShaderModelsEnum.h"
};
#undef ENUM_ITEM

// ---------------------------------------------------------------------------------------------------------------------

const CShaderSourceDescriptor& CShaderProgramDescriptor::GetShaderSource(CShaderProgramDescriptor::ELanguageType _Language) const 
{
	return *m_SourceDescriptor[_Language];
}

// ---------------------------------------------------------------------------------------------------------------------

void CShaderProgramDescriptor::ReadDescriptorFile(const char* _pFileName)
{
	const IFileSystem* pFileSystem = CMain::GetInstance().GetFileSystem();
	CXMLSerializer Serializer(ISerializer::Reading, *pFileSystem, _pFileName);
	
	Serializer.SerializeBlockStart("ShaderSource");
	
	#define ENUM_ITEM(_Name, _Class) SerializeDescriptor<_Class>(Serializer, _Name, #_Name);
	#include "CRL_ShaderModelsEnum.h"
	#undef ENUM_ITEM
	
	Serializer.SerializeBlockEnd("ShaderSource");
}

CB_SUBNAMESPACE_END